package com.dao;

import java.util.ArrayList;

import org.springframework.stereotype.Controller;

import com.hibernate.pojo.Product;

@Controller("productDao")
public class ProductDao extends Basedao {

	public boolean update(Product product){
		try {
			getSession().save(product);
			return true;
		} catch (Exception e) {
		}
		return false;
	}
	
	public ArrayList<Product> getall(){
		return (ArrayList<Product>) getSession().createQuery("from Product").list();
	}
	
	public Product get(int id){
		return (Product)getSession().createQuery("from Product p where p.id=?").setInteger(0, id).uniqueResult();
	}
}
